<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){

	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择订单','error','order.list/');
	}
	$pay_types=get_pay_types();
	$ispay=array('0'=>'未支付','1'=>'已支付');
	$item=$this->model('order')->get_order($id);
	foreach($item['goods'] as &$gv){
		$gv['title'].='['.$gv['optiondata'].']';
	}
	$item['status']=$this->order_status[$item['status']];	
	$item['paytype']=$pay_types[$item['paytype']];
	$item['member']=model('core/member')->detail($item['mid'],array('nickname','avatar','mobile'));
	//$item['address']=model('core/member')->get_address_str($item['addressid']);
	$address=pdo_get('core_address',array('id'=>$item['addressid']));
	$item['address']=array(
		'address'=>model('core/member')->get_address_str($item['addressid']),
		'mobile'=>$address['mobile'],
		'name'=>$address['name'],
	);
	$htmls=array();
	$htmls[]=array(
		'type'=>'look',
		'desc'=>'基本信息',		
		'look'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'member.nickname','title'=>'买家昵称','type'=>'string'),
			array('name'=>'member.avatar','title'=>'买家头像','type'=>'image'),
			array('name'=>'member.mobile','title'=>'买家电话','type'=>'string'),
			array('name'=>'price','title'=>'订单金额','type'=>'string'),
			array('name'=>'goodsprice','title'=>'商品金额','type'=>'string'),
			array('name'=>'discountprice','title'=>'运费','type'=>'string'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'time'),
			array('name'=>'status','title'=>'订单状态','type'=>'string'),
		)
	);
	//商品信息
	$htmls[]=array(
		'type'=>'look',
		'desc'=>'商品清单',		
		'look'=>array(
			array('name'=>'goods','title'=>'商品信息','type'=>'array','list'=>array(
				array('type'=>'string','name'=>'title','title'=>'商品名称'),
				array('type'=>'image','name'=>'image','title'=>'商品图片'),
				array('type'=>'string','name'=>'price','title'=>'购买单价'),
				array('type'=>'string','name'=>'total','title'=>'购买数量'),
			)),
		)
	);
	//支付
	$pay_show=array(
		'type'=>'look',
		'desc'=>'支付',
		'look'=>array(
			array('name'=>'ispay','title'=>'是否支付','type'=>'string'),
		),
	);
	if($item['ispay']){
		$pay_show['look'][]=array('name'=>'paytype','title'=>'支付方式','type'=>'string');
		$pay_show['look'][]=array('name'=>'paytime','title'=>'支付时间','type'=>'time');
	}
	$item['ispay']=$ispay[$item['ispay']];
	$htmls[]=$pay_show;
	//收货信息
	$htmls[]=array(
		'type'=>'look',
		'desc'=>'收货信息',
		'look'=>array(
			array('name'=>'address.address','title'=>'收货地址','type'=>'string'),
			array('name'=>'address.name','title'=>'收货人姓名','type'=>'string'),
			array('name'=>'address.mobile','title'=>'收货人电话','type'=>'string'),
		),
	);
	$express=$this->get('order_express',array('orderid'=>$item['id']));
	if($express){
		//发货信息
		$express['express_id']=$this->express_types[$express['express_id']]['name'];
		$item['express']=$express;
		$htmls[]=array(
			'type'=>'look',
			'desc'=>'发货货信息',
			'look'=>array(
				array('name'=>'express.createtime','title'=>'发货时间','type'=>'time'),
				array('name'=>'express.express_id','title'=>'快递公司','type'=>'string'),
				array('name'=>'express.expresssn','title'=>'快递单号','type'=>'string'),
			),
		);
	}
	$return['htmls']=$htmls;
	$return['item']=$item;
	exi($return);
}